/**
 * @name SelectedTree
 * @author
 * @desc
 * @version
 */

import React, { Component } from "react"
import { Icon, Empty } from "antd"
import styles from "./styles.module.less"

class SelectedTree extends Component {
  static default = {
    data: [],
    onDel: val => {}
  }

  render() {
    const { data = [], onDel } = this.props
    return (
      <div>
        <div className={styles.head}>
          <span className={styles.title}>已选树节点</span>
          {data.length !== 0 && (
            <span className={styles.clear} onClick={() => onDel(-1)}>
              清除
            </span>
          )}
        </div>

        {data instanceof Array && data.length > 0 ? (
          <div className={styles.info}>
            {data.map(v => (
              <div className={styles.item} key={v.node.key}>
                <span className={styles.name}>{v.node.props.title}</span>
                <Icon type="close" onClick={() => onDel(v)} />
              </div>
            ))}
          </div>
        ) : (
          <Empty />
        )}
      </div>
    )
  }
}
export default SelectedTree
